﻿<html DIR="LTR" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ddue="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
  <head>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8" />
    <META NAME="save" CONTENT="history" />
    <title>getIndexInfo Method (SQLServerDatabaseMetaData)</title>
    
    <link rel="stylesheet" type="text/css" href="../local/Classic.css">
      
    </link>
    
    <script src="../local/script.js">
      
    </script><script src="../local/script_main.js">&amp;nbsp;</script>
  </head>
  <body>
    <!--Topic built:03/05/2009 21:01:45-->

    
    
    
    
    
    
    
    
    
    <div id="header">
      <table width="100%" id="topTable"><tr>
          <td align="left">
            <span id="headerBold">getIndexInfo Method (SQLServerDatabaseMetaData)</span>
          </td>
          <td align="right">
            
          </td>
        </tr></table>
      
      
      
    </div>
    <div id="mainSection">
      
        
        
		<font color="DarkGray"> </font> <p /> <p />
	
        <div id="introductionSection" class="section">
    <p>Retrieves a description of the indexes and statistics for the given table.</p>
  </div><h1 class="heading">Syntax</h1><div id="syntaxSection" class="section"><div class="sampleCode"><span codeLanguage="other"><pre>
public java.sql.ResultSet <b>getIndexInfo</b>(java.lang.String <i>cat</i>,
                                       java.lang.String <i>schema</i>,
                                       java.lang.String <i>table</i>,
                                       boolean <i>unique</i>,
                                       boolean <i>approximate</i>)</pre></span></div><h1 class="heading">Parameters</h1><div id="parametersSection" class="section" name="collapseableSection">
    <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">
        <i>cat</i>
      </p>
      <p xmlns="">A<b> String </b>that contains the catalog name.</p>
      <p xmlns="">
        <i>schema</i>
      </p>
      <p xmlns="">A<b> String </b>that contains the schema name.</p>
      <p xmlns="">
        <i>table</i>
      </p>
      <p xmlns="">A<b> String </b>that contains the table name.</p>
      <p xmlns="">
        <i>unique</i>
      </p>
      <p xmlns="">
        <b>true</b> if only indexes for unique values are returned. <b>false</b> if all indexes are returned.</p>
      <p xmlns="">
        <i>approximate</i>
      </p>
      <p xmlns="">
        <b>true</b> if the results reflect approximate or out-of-date values. <b>false</b> if the results are accurate.</p>
    </content>
  </div></div><h1 class="heading">Return Value</h1><div id="returnValueSection" class="section" name="collapseableSection">
    <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">A <a href="eaffcff1-286c-459f-83da-3150778480c9.htm">SQLServerResultSet</a> object.</p>
    </content>
  </div><h1 class="heading">Exceptions</h1><div id="exceptionsSection" class="section" name="collapseableSection">
    <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">
        <a href="af5ef257-7cf6-4db3-b1ee-07d22d82bef1.htm">SQLServerException</a>
      </p>
    </content>
  </div><h1 class="heading">Remarks</h1><div id="remarksSection" class="section" name="collapseableSection">
    <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">This <b>getIndexInfo</b> method is specified by the <b>getIndexInfo</b> method in the java.sql.DatabaseMetaData interface.</p>
      <p xmlns="">The result set returned by the <b>getIndexInfo</b> method will contain the following information:</p>
      <table width="100%" cellspacing="0" cellpadding="0" border="1" style="background-color: #CCCCCC;" xmlns=""><tr>
            <th>
              Name
            </th>
            <th>
              Type
            </th>
            <th>
              Description
            </th>
          </tr><tr>
          <td>
            <p>TABLE_CAT</p>
          </td>
          <td>
            <p>
              <b>String</b>
            </p>
          </td>
          <td>
            <p>The name of the database in which the specified table resides.</p>
          </td>
        </tr><tr>
          <td>
            <p>TABLE_SCHEM</p>
          </td>
          <td>
            <p>
              <b>String</b>
            </p>
          </td>
          <td>
            <p>The schema for the table.</p>
          </td>
        </tr><tr>
          <td>
            <p>TABLE_NAME</p>
          </td>
          <td>
            <p>
              <b>String</b>
            </p>
          </td>
          <td>
            <p>The name of the table.</p>
          </td>
        </tr><tr>
          <td>
            <p>NON_UNIQUE</p>
          </td>
          <td>
            <p>
              <b>boolean</b>
            </p>
          </td>
          <td>
            <p>Indicates whether the index values can be non-unique.</p>
          </td>
        </tr><tr>
          <td>
            <p>INDEX_QUALIFIER</p>
          </td>
          <td>
            <p>
              <b>String</b>
            </p>
          </td>
          <td>
            <p>The name of the index owner. It will be null when TYPE is tableIndexStatistic.</p>
          </td>
        </tr><tr>
          <td>
            <p>INDEX_NAME</p>
          </td>
          <td>
            <p>
              <b>String</b>
            </p>
          </td>
          <td>
            <p>The name of the index.</p>
          </td>
        </tr><tr>
          <td>
            <p>TYPE</p>
          </td>
          <td>
            <p>
              <b>short</b>
            </p>
          </td>
          <td>
            <p>The type of the index. It can be one of the following values:</p>
            <p>tableIndexStatistic (0)</p>
            <p>tableIndexClustered (1)</p>
            <p>tableIndexHashed (2)</p>
            <p>tableIndexOther (3)</p>
          </td>
        </tr><tr>
          <td>
            <p>ORDINAL_POSITION</p>
          </td>
          <td>
            <p>
              <b>short</b>
            </p>
          </td>
          <td>
            <p>The ordinal position of the column in the index. The first column in the index is 1.</p>
          </td>
        </tr><tr>
          <td>
            <p>COLUMN_NAME</p>
          </td>
          <td>
            <p>
              <b>String</b>
            </p>
          </td>
          <td>
            <p>The name of the column.</p>
          </td>
        </tr><tr>
          <td>
            <p>ASC_OR_DESC</p>
          </td>
          <td>
            <p>
              <b>String</b>
            </p>
          </td>
          <td>
            <p>The order used in the collation of the index. It can be one of the following values:</p>
            <p>A (ascending)</p>
            <p>D (descending)</p>
            <p>NULL (not applicable)</p>
            <div style="margin: .5em 1.5em .5em 1.5em"><b>Note: </b>
              SQL Server always returns "A".<p />
            </div>
          </td>
        </tr><tr>
          <td>
            <p>CARDINALITY</p>
          </td>
          <td>
            <p>
              <b>int</b>
            </p>
          </td>
          <td>
            <p>The number of rows in the table or unique values in the index.</p>
          </td>
        </tr><tr>
          <td>
            <p>PAGES</p>
          </td>
          <td>
            <p>
              <b>int</b>
            </p>
          </td>
          <td>
            <p>The number of pages used to store the index or table.</p>
          </td>
        </tr><tr>
          <td>
            <p>FILTER_CONDITION</p>
          </td>
          <td>
            <p>
              <b>String</b>
            </p>
          </td>
          <td>
            <p>The filter condition.</p>
            <div style="margin: .5em 1.5em .5em 1.5em"><b>Note: </b>
              SQL Server always returns null.<p />
            </div>
          </td>
        </tr></table>
      <div style="margin: .5em 1.5em .5em 1.5em" xmlns=""><b>Note: </b>
        For more information about the data returned by the <b>getIndexInfo</b> method, see "sp_indexes (Transact-SQL)" in SQL Server Books Online.<p />
      </div>
    </content>
  </div><h1 class="heading">Example</h1><div id="codeExampleSection" class="section" name="collapseableSection">
    <description xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <content>
        <p xmlns="">The following example demonstrates how to use the <b>getIndexInfo</b> method to return information about the indexes and statistics of the Person.Contact table in the SQL Server 2005 AdventureWorks sample database.</p>
      </content>
    </description>
    <div class="sampleCode"><span codeLanguage="other"><pre>public static void executeGetIndexInfo(Connection con) {
   try {
      DatabaseMetaData dbmd = con.getMetaData();
      ResultSet rs = dbmd.getIndexInfo("AdventureWorks", "Person", "Contact", false, true);
      ResultSetMetaData rsmd = rs.getMetaData();

      // Display the result set data.
      int cols = rsmd.getColumnCount();
      while(rs.next()) {
         for (int i = 1; i &lt;= cols; i++) {
            System.out.println(rs.getString(i));
         }
      }
      rs.close();
   } 

   catch (Exception e) {
      e.printStackTrace();
   }
}</pre></span></div>
  </div><span id="seeAlsoSpan"><h1 class="heading">See Also</h1></span><div id="seeAlsoSection" class="section" name="collapseableSection"><a href="8b8049d0-8c6d-4476-866b-098709f37eec.htm">SQLServerDatabaseMetaData Class</a><br /><a href="772de447-c922-4b85-8e10-5f0d9277966c.htm">SQLServerDatabaseMetaData Methods</a><br /><a href="327ba0bc-438a-494c-b119-1cd4a096bb58.htm">SQLServerDatabaseMetaData Members</a><br /><br /></div><!--[if gte IE 5]>
			<tool:tip element="seeAlsoToolTip" avoidmouse="false"/><tool:tip element="languageFilterToolTip" avoidmouse="false"/><tool:tip element="roleInfoSpan" avoidmouse="false"/>
		<![endif]-->
      <div id="footer" class="section">
        
		<hr />
		
		<span id="fb" class="feedbackcss">
			
			
		</span>
		
		<a href="9bad553b-9e70-4696-8499-2e35f772a1e0.htm">
			
			© 2009 Microsoft Corporation. All rights reserved.
		</a>
 	
	
      </div>
    </div>
  </body>
</html>